<?php
	require_once('SchemaManager.php');
	require_once('SchemaManagerImpl.php');
	
	function handleError($errno, $errstr, $errfile, $errline, array $errcontext) {
	    // error was suppressed with the @-operator
    	if (0 === error_reporting()) {
        	return false;
    	}
	    throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
	}
	set_error_handler('handleError');
	
	try {
		$xml = new SchemaManagerImpl();
		$xml->setSchema("blacknovaSchema.xml", true);
		$xml->parseSchema();
		$xml->createDatabase(NULL, "localhost", "user", "password", "database");
		
		$sqlErrors = $xml->getSqlErrors();
		if (!empty($sqlErrors)) {
			print_r($sqlErrors);
			echo "\n\n<br/><br/>\n\n";
			print_r($xml->getSql());
		} else {
			echo "Database created successfully.";
		}
	} catch (ErrorException $e) {
		echo $e->getMessage();
	}
?>